using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Text.RegularExpressions;

public partial class UserDefinedFunctions
{
    public static readonly RegexOptions Options = RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.CultureInvariant;

    [Microsoft.SqlServer.Server.SqlFunction]
    public static SqlBoolean fnRegEx_IsMatch(string inputValue, string searchPattern)
    {
        if (inputValue == null || searchPattern == null)
            return false;

        return System.Text.RegularExpressions.Regex.IsMatch(inputValue, searchPattern, Options);
    }
}
